﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net;
using DcsGauges.Shared.Network;
using System.Windows.Media.Imaging;
using DcsGauges.Shared.Packets;
using NLog;

namespace DcsGauges.Server.Network
{
    class DcsA10Channel : IGameChannel
    {
        #region Field / Properties

        private INetworkChannel networkChannel          = null;      
        public BitmapSource     Logo                    { get { return null; }}

        #endregion


        #region Constructors

        public DcsA10Channel(INetworkChannel channel)
        {
            this.networkChannel                             = channel;
            this.networkChannel.DataPacketReceivedEvent     += new EventHandler<PacketReceivedEventArgs<DataPacket>>(OnNetworkChannelHandleDataPacketReceivedEvent);
        }

        #endregion


        #region Interface Implementation


        #region Fields / Properties

        public string GameName
        {
            get { return "DCS-A10 Warthog"; }
        }

        #endregion


        #region Interface Implementation
        
        #region Operations

        public void IssueCommand(CommandsPacket packet)
        {
            this.networkChannel.Send(packet);
        }

        #endregion

        #endregion


        #region Event Handlers

        private void OnNetworkChannelHandleDataPacketReceivedEvent(object sender, PacketReceivedEventArgs<DataPacket> e)
        {
            this.FireDataPacketReceivedEvent(e.Packet);
        }

        #endregion


        #region Events

        public event EventHandler<PacketReceivedEventArgs<DataPacket>>  DataPacketReceivedEvent;

        #endregion


        #region Helpers

        private void FireDataPacketReceivedEvent(DataPacket dataPacket)
        {
            if (this.DataPacketReceivedEvent != null)
            {
                this.DataPacketReceivedEvent(this, new PacketReceivedEventArgs<DataPacket>(dataPacket));
            }
        }

        #endregion


        #endregion
    }
}
